package org.ace.communicate
{
	import flash.text.TextField;
	
	import org.ace.model.MyModel;
	import org.ace.model.SocketModel;
	import org.ace.protocol.Protocol;
	import org.ace.view.GameSceneHandler;
	import org.ace.view.LoginHandler;

	public class MessageReceived
	{
		private static var messageReceived:MessageReceived;
		public function MessageReceived()
		{
			
		}
		public static function getMessageReceived():MessageReceived{
			if(messageReceived==null){
				messageReceived=new MessageReceived();
			}
			return messageReceived;
		}
		public function write(type:int,area:int,command:int,message:Object=null):void{
			var sm:SocketModel=new SocketModel();
			sm.type=type;
			sm.area=area;
			sm.command=command;
			sm.message=message;
			SocketCommunicate.getSocket().write(sm);
		}
		public function received(message:SocketModel):void{
			switch(message.type){
				case Protocol.TYPE_LOGIN:
					LoginHandler.getLogin().process(message);
					break;
				case Protocol.TYPE_MAP:
					GameSceneHandler.getScene().process(message);
					break;
			}
		}
	}
}